<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('双向打分配置')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }
</style>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="dv">
    <form class="form-horizontal m" id="form-twoWay-edit" AUTOCOMPLETE="OFF">
        <input type="hidden" id="userId" name="userId" th:value="${userId}"/>
        <input type="hidden" id="examineeName" name="examineeName" th:value="${examineeName}"/>
        <input type="hidden" id="badge" name="badge" th:value="${badge}"/>

        <h4 class="form-header h4">基本信息</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input th:value="${user.examineeName}" disabled="disabled" class="form-control" type="text"
                               placeholder="姓名" required/>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">工号：</label>
                    <div class="col-sm-8">
                        <input th:value="${user.badge}" disabled="disabled" class="form-control" type="text"
                               placeholder="工号" required/>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">可打分人及部门：</label>
                    <div class="col-sm-8">
                        <input th:value="${userDeptListStr}" disabled="disabled" class="form-control" type="text"
                               placeholder="可打分人及部门" required/>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">职能部门：</label>
                    <div class="col-sm-8">
                        <select id="functionId" name="functionId" class="form-control" required>
                            <option value="">请选择</option>
                            <option th:each="userDept:${userDeptList}"
                                    th:selected="${twoWay.function_dept_id == userDept.deptId}"
                                    th:value="${userDept.deptId }"
                                    th:text="${userDept.nameDept }"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">职能部门占比：</label>
                    <div class="col-sm-8">
                        <input th:value="${twoWay.function_proportion}" name="function_proportion"
                               onkeyup="clearNoNum(this)" class="form-control" type="text"
                               placeholder="职能部门占比" required/>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">项目部门：</label>
                    <div class="col-sm-8">
                        <select id="proId" name="proId" class="form-control" required>
                            <option value="">请选择</option>
                            <option th:each="userDept:${userDeptList}"
                                    th:selected="${twoWay.pro_dept_id == userDept.deptId}"
                                    th:value="${userDept.deptId }"
                                    th:text="${userDept.nameDept }"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">项目部门占比：</label>
                    <div class="col-sm-8">
                        <input th:value="${twoWay.pro_proportion}" name="pro_proportion" onkeyup="clearNoNum(this)"
                               class="form-control" type="text"
                               placeholder="项目部门占比" required/>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>

<script th:inline="javascript">
    var prefix = ctx + 'acvEmpManage';

    $(function () {


    })

    function submitHandler() {
        if ($.validate.form()) {
            var functionId = $("#functionId").val();
            var proId = $("#proId").val();
            if (functionId == proId) {
                $.modal.alertWarning("职能部门和项目部不能选择同一部门");
                return false;
            }
            var data = $("#form-twoWay-edit").serializeArray();
            $.operate.save(prefix + "/twoWay", data);
        }
    }

    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');//只能输入两个小数
        if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value = parseFloat(obj.value);
        }
    }

</script>

</body>
</html>